﻿<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>发表问题</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="css/head.css"/>
  <link rel="stylesheet" href="layui/css/layui.css">

  <link rel="stylesheet" href="css/global.css">
  <style>
    .userface {
      float: left;
      margin-left: 30px;
      width: 57px;
      height: 57px;
      float: left;
    }
  </style>

<script src="layui/layui.js"></script>
  <script src="js/jquery-1.7.2.min.js"></script>
  <script src="js/plugins/js-cookie/js.cookie.min.js"></script>
  <script src="js/vue/vue.min.js"></script>
  <script src="js/common.js"></script>
  <script src="js/plugins/jquery-form/jquery.form.js"></script>


</head>
<body >


<div id="app" v-cloak>
  <div class="dvhead">
    <div class="dvlogo"><a href="index.html">你问我答</a></div>
    <div class="dvsearch">10秒钟<a href="register.html">注册</a>账号，找到你的同学</div>
    <div class="dvreg" v-if="user != null">
      <img class="userface" :src="user.avatar"  style="border-radius: 50%; overflow: hidden; margin-top: 15px;background-color: white;">
    </div>
    <div class="dvreg" v-if="user == null">
      已有账号，立即&nbsp;<a href="login.html">登录</a>
    </div>
  </div>

  <div class="main layui-clear">
    <div class="fly-panel" pad20>
      <h2 class="page-title">发表问题</h2>
      <!-- <div class="fly-none">并无权限</div> -->
      <div class="layui-form layui-form-pane">
          <form id="answerId" action="/questions/add" method="post">
            <input type="hidden"  name="askId">
            <input type="hidden"  name="content" >
          <div class="layui-form-item">
            <label for="L_title" class="layui-form-label">标题</label>
            <div class="layui-input-block">
              <input type="text" id="L_title" name="title" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item layui-form-text">
            <div class="layui-input-block">
              <div class="editor">
                <textarea id="content" style="width:1040px;height:450px;visibility:hidden;"></textarea>
              </div>
            </div>
            <label for="L_content" class="layui-form-label" style="top: -2px;">描述</label>
          </div>
          <div class="layui-form-item">
            <label for="L_title" class="layui-form-label">悬赏</label>
            <div class="layui-input-block">
              <input type="number"  name="score" required lay-verify="required" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-form-item">
            <button class="layui-btn" id="btn" type="button">立即发布</button>
          </div>
        </form>
      </div>
    </div>
  </div>

</div>


<script type="text/javascript" charset="utf-8" src="js/kindeditor.js"></script>
<script type="text/javascript">
  KE.show({
    id : 'content',
    resizeMode : 1,
    //cssPath : './index.css',
    items : [
      'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
      'removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
      'insertunorderedlist', 'emoticons', 'image', 'link']
  });


  layui.use(['layer', 'form'], function(){
    var layer = layui.layer,form = layui.form;
    var user = getUserInfo()
    if(!user){
      layer.confirm("请先登录，点击跳转登录页面",{icon: 3, title: '系统提示'},function (index) {
        layer.close(index);
        window.location.href = "login.html"
      });
    }

    $("#btn").click(function () {
      $("#answerId [name='askId']").val(user.id)
      $("#answerId [name='content']").val(KE.util.getData("content"))
      $("#answerId").ajaxSubmit(function (data) {
        if(data.code == 200){
          window.location.href = "/";
        }else{
          layer.msg("提问失败，请检查相应的参数~")
        }

      })
    })
  });







</script>







</body>
</html>